	var citys = function(defaultpid) {
		$.ajax({
			url: URL+'area/ajax_list_children/' + defaultpid,
			type: 'GET',
			dataType: 'json',
			success: function(data) {
				var data = data.content;
				$('.Citylist ul').html('')
				$('.Citylist ul').append('<li data-id="0" li-value="0">'+all+'</li>')
		
				for (var i = 0; i < data.data.length; i++) {
					//$('.Country .select_option').append('<li class="" style="cursor: pointer;">'+data.data[i].short_name+'</li>')
					$('.Citylist ul').append('<li data-id="' + data.data[i].id + '" data-value="' + data.data[i].short_name + '">' + data.data[i].short_name + '</li>')
				}
				// var Cityselect = $('.Cityselect'); //国家
				// createSelect(Cityselect);
				$('.Citylist ul').find('li').eq(0).addClass('selected')
				$('.Cityselect_box').html($('.Citylist ul').find('li').eq(0).html());
				$('.Cityselect_box').attr('data-id', $('.Citylist ul').find('li').eq(0).attr('data-id'))
				// 默认的
				var country = $('.Countrylist li').eq(0).attr('data-id')
				var city = $('.Citylist li').eq(0).attr('data-id')
				var cityname = $('.Citylist li').eq(0).html()
				

			}
		})
	}


	// 切换城市地图
	$(document).on('click', '.Citylist li', function(event) {
		$('.Cityselect_box').html($(this).html())
		var defaultcid = $(this).attr('data-id')
		console.log(defaultcid)
		$(this).addClass('selected').siblings().removeClass('selected');
		$('.Cityselect_box').attr('data-id', defaultcid)
		var country = $('.Countryselect_box').attr('data-id')
		var city = $(this).attr('data-id')
		var cityname = $(this).html()

	});






var order= ''
var keyword = decodeURIComponent((new RegExp('[?|&]keyword=' + '([^&;]+?)(&|#|;|$)', "ig").exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null;
var country = decodeURIComponent((new RegExp('[?|&]country=' + '([^&;]+?)(&|#|;|$)', "ig").exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null;
var city = decodeURIComponent((new RegExp('[?|&]city=' + '([^&;]+?)(&|#|;|$)', "ig").exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null;
var order = decodeURIComponent((new RegExp('[?|&]order=' + '([^&;]+?)(&|#|;|$)', "ig").exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null;
if (keyword) {
	var hrefurl = URL+"touroute/search/?keyword="+keyword+'&country='+country+'&city='+city
}else{
	var hrefurl = URL+"touroute/search/?keyword="+''+'&country='+country+'&city='+city
}



// 点击排序
$('.Duration').click(function(event) {
	if ($(this).hasClass('search_cur')) {
		order = 'duration_asc'
		window.location.href = hrefurl + '&order=' + order
	} else {
		order = 'duration_desc'
		window.location.href = hrefurl + '&order=' + order
	}
});
$('.Price').click(function(event) {
	if ($(this).hasClass('search_cur')) {
		order = 'price_asc'
		window.location.href = hrefurl + '&order=' + order
	} else {
		order = 'price_desc'
		window.location.href = hrefurl + '&order=' + order
	}
});


// 路线排序显示当前状态
$('.Price ,.Duration').click(function(event) {
	$(this).toggleClass('search_cur');
});
if (order =='duration_asc') {
	$('.Duration ').addClass('search_cur')
	
}else if (order =='price_asc') {
	$('.Price ').addClass('search_cur')
}

$('.Price').click(function(event) {
	$('.Duration').removeClass('search_cur')
});
$('.Duration').click(function(event) {
	$('.Price').removeClass('search_cur')
});



// 切换商家，路线搜索选项
$('.tab_search span').click(function(event) {
	if (!$(this).hasClass('tab_search_cur')) {
		$(this).toggleClass('tab_search_cur');
	}
	
	$(this).siblings().removeClass('tab_search_cur');
	if ($('.search_sj ').hasClass('tab_search_cur')) {
		$('.Price  ,.Duration ').hide()
	}else{
		$('.Price  ,.Duration ').show()
	}
});

$('.searchBtn ,.tab_search span').click(function(event) {
	var h_val = JSON.parse(getCookie('history'))
	h_val.unshift($('.searchInput').val())
	if (h_val.length > 3) {
		h_val.length = 3
	}else if(h_val.length > 3){
		h_val.length = h_val.length
	}
	var history = JSON.stringify(h_val);
	SetCookie('history', history)
	var keyword = $('.searchInput').val()
	var country = $('.Countryselect_box').attr('data-id')
	var city = $('.Cityselect_box').attr('data-id')
	var URLz = window.location.host
		// console.log(URLz)
	if($('.search_sj').hasClass('tab_search_cur')){
		// 跳转到商家
		window.location.href = 'http://' + URLz + "/merchant/search/?keyword=" + keyword + '&country=' + country + '&city=' + city
	}else{
		// 跳转到路线
		window.location.href = 'http://' + URLz + "/touroute/search/?keyword=" + keyword + '&country=' + country + '&city=' + city
	}
	
});


// $('.tab_search span').click(function(event) {
// 	var h_val = JSON.parse(getCookie('history'))
// 	h_val.unshift($('.searchInput').val())
// 	if (h_val.length > 3) {
// 		h_val.length = 3
// 	}else if(h_val.length > 3){
// 		h_val.length = h_val.length
// 	}
// 	var history = JSON.stringify(h_val);
// 	SetCookie('history', history)
// 	var keyword = $('.searchInput').val()
// 	var country = $('.Countryselect_box').attr('data-id')
// 	var city = $('.Cityselect_box').attr('data-id')
// 	var URLz = window.location.host
// 		// console.log(URLz)
// 	if($('.search_sj').hasClass('tab_search_cur')){
// 		// 跳转到商家
// 		window.location.href = 'http://' + URLz + "/touroute/search/?keyword=" + keyword + '&country=' + country + '&city=' + city
// 	}else{
// 		// 跳转到路线
// 		window.location.href = 'http://' + URLz + "/merchant/search/?keyword=" + keyword + '&country=' + country + '&city=' + city
// 	}
	
// });

